package com.sg.business.commons.field;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.forms.IMessageManager;

import com.mobnut.db.model.PrimaryObject;
import com.sg.business.commons.editingsupport.WorksPerformenceContentTable;
import com.sg.business.model.Work;
import com.sg.widgets.part.editor.fields.AbstractFieldPart;
import com.sg.widgets.part.editor.fields.IEditorPartDelegator;
import com.sg.widgets.registry.config.FieldConfigurator;

public class WorksPerformenceField implements IEditorPartDelegator {

	public class WorksPerformenceFieldPart extends AbstractFieldPart {

		private WorksPerformenceContentTable control;

		public WorksPerformenceFieldPart(Composite parent,
				FieldConfigurator cfield, IEditorInput input) {
			super(parent, cfield, input);
		}

		@Override
		public Control getControl() {
			return  control;
		}

		@Override
		protected void setEditable(boolean editable) {
		}

		@Override
		protected void presentValue(PrimaryObject data, Object value,
				String presentValue) {
		}

		@Override
		protected void createControl(Composite parent) {
			Work data = (Work) getInputData();
			control = new WorksPerformenceContentTable(parent, data);
			GridData td = new GridData(SWT.FILL, SWT.TOP, true, false,
					space == 0 ? controlSpace : space, 1);
			td.heightHint = 200;
			control.setLayoutData(td);
		}

		@Override
		protected Object getValueForUpdate(IMessageManager messageManager) {
			return null;
		}

	}

	public WorksPerformenceField() {
	}

	@Override
	public AbstractFieldPart getEditorPart(Composite parent,
			FieldConfigurator cfield, IEditorInput input) {
		return new WorksPerformenceFieldPart(parent,cfield,input);
	}

}
